<?php
include_once("king_head.php");
include_once("config.php");
$ID=$_POST["ID"];
if(isset($_POST["btn_del"]))
{
unlink("downloads_".$ID."/".$del_id);
}
?>
<H2> Reseller Uploads</H2>
<form action="reseller_uploads.php?site_id=101" method="post" name="frm">
  <table width="673" border="0" align="center">
    <tr>
      <td height="53" colspan="2"><div align="center">Select Reseller: 
          <select name="res_id">
		  <?php
		  $q="select * from reseller";
		  $r=mysql_query($q);
		  while($rec=mysql_fetch_array($r))
		  {?>
		  <option value="<?php echo $rec["site_id"];?>"><?php echo $rec["fname"];?></option>
		  <?php }
		  ?>
              </select>
			  <?php
			  if(isset($_POST["res_id"]))
			  {
			  $ql="select * from reseller where site_id=".$res_id;
			  $rl=mysql_query($ql);
			  $rec=mysql_fetch_array($rl);
			  $uid=$rec["uid"];
			  $pwd=$rec["pwd"];
			  echo "<BR><a href=\"cpanel.php?uid=".$uid."&pwd=".$pwd."\" target=\"_blank\">Access Control Panel(".$uid.")</a>";
			  $qry="SELECT min(id) FROM site_page WHERE site_id=".$res_id;
			  //echo $qry;
			  $result = mysql_query($qry);
			  	if($page_data=mysql_fetch_row($result))
				{
					$pid=$page_data[0];
					echo "<BR><a href=\"page.php?site_id=".$res_id."&pid=".$pid."\" target=\"_blank\">Access Home Page(".$uid.")</a>";
				}
				}	
			  ?>
          <BR><input type="submit" value="OK" />
      </div></td>
    </tr>
    <tr>
      <td width="332"><div align="right">
        Uploaded Files:<BR><select name="del_id">
         <?php
		$hnd=opendir("./downloads_".$res_id);
		while($file=readdir($hnd))
		{	
			if($file!="." && $file!=".." && $file!="WS_FTP.LOG" && $file!="Thumbs.db")
			{?>
			<option value="<?php echo $file; ?>"><?php echo $file;?></option>
		<?php }	
		}
		closedir($hnd);?>
        </select>
      </div></td>
      <td width="331"> Download Files:<BR>
        <select name="dwn_id">
		<?php
		$hnd=opendir("./downloads_".$res_id);
		while($file=readdir($hnd))
		{	
			if($file!="." && $file!=".." && $file!="WS_FTP.LOG" && $file!="Thumbs.db")
			{?>
			<option value="<?php echo $file; ?>"><?php echo $file;?></option>
		<?php }	
		}
		closedir($hnd);?>
      </select>      </td>
    </tr>
    <tr>
      <td><div align="right"><input type="hidden" name="ID" value="<?php echo $res_id;?>" />
        <input type="submit" name="btn_del" value="Delete" />
      </div></td>
      <td><input type="button" name="btn_dwn" value="Download" onclick="javascript: window.open('f_dwnld.php?site_id='+ document.frm.ID.value + '&fname=' + document.frm.dwn_id[document.frm.dwn_id.selectedIndex].value);"/></td>
    </tr>
  </table>
</form>
<?php
include_once("king_foot.php");
?>
<!--"javascript: window.open('f_dwnld.php?site_id='+document.frm.ID.value+ '&fname='+ document.frm.dwn_id[document.frm.dwn_id.selectedIndex].value);"
javascript: window.open('downloads_'+document.frm.ID.value+'/'+document.frm.dwn_id[document.frm.dwn_id.selectedIndex].value);-->